﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Mbs;
using Mbs.Windows;
using Mbs.ComponentModel.Container;

namespace ElementMap.Module
{
    public interface IElementMapView:ISmartPartView
    {
    }

    public interface IElementMapPresenter : ISmartPartPresenter<IElementMapView>
    {
    }

    [Component(Service=typeof(IElementMapPresenter))]
    public class ElmentMapPresenter : SmartPartPresenter<IElementMapView>,IElementMapPresenter
    {
        public ElmentMapPresenter() : base(SmartPartNames.ElementMapView) { }

        public override IEnumerator<IDisposable> Subscribe()
        {
            yield return CommandNames.ShowCustomer.Subscribe<EventArgs>((s, e) => MessageBox.Show("Show Customer"));
            yield return CommandNames.EnableShowCustomer.Subscribe<EventArgs>((s, e) => EnableShowCustomer(true));
            yield return CommandNames.DisableShowCustomer.Subscribe<EventArgs>((s, e) => EnableShowCustomer(false));
            yield return CommandNames.HideShowCustomer.Subscribe<EventArgs>((s, e) => CommandNames.ShowCustomer.Command().Visible = false);
        }

        private static void EnableShowCustomer(bool enabled)
        {
            CommandNames.ShowCustomer.Command().Enabled = enabled;
            CommandNames.EnableShowCustomer.Command().Enabled = !enabled;
            CommandNames.DisableShowCustomer.Command().Enabled = enabled;
        }
    }
}
